<?php
if ( ! get_option('violinesth') && function_exists('register_sidebar') ) {
		register_sidebar(array(
		'name' => 'Left Sidebar',
		'id' => 'left-sidebar',
		'before_widget' => '<li>',
	        'after_widget' => '</li>',
        	'before_title' => '<h4>',
	        'after_title' => '</h4>',
	));
}

if ( function_exists('register_sidebar') )
    register_sidebar(array(
	'name' => 'Right Sidebar',
	'id' => 'right-sidebar',
	'before_widget' => '<li>',
        'after_widget' => '</li>',
        'before_title' => '<h4>',
        'after_title' => '</h4>',
));

$themecolors = array(
	'bg' => 'ffffff',
	'text' => '000000',
	'link' => '333333'
);

define('HEADER_TEXTCOLOR', '');
define('HEADER_IMAGE', '%s/images/green.jpg'); // %s is theme dir uri
define('HEADER_IMAGE_WIDTH', 1024);
define('HEADER_IMAGE_HEIGHT', 279);
define('NO_HEADER_TEXT', true );

$content_width = 500;

function violinesth_admin_header_style() {
?>
<style type="text/css">
#headimg{
	background: url(<?php header_image() ?>) no-repeat;
	background-repeat: no-repeat;
	height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
	width:<?php echo HEADER_IMAGE_WIDTH; ?>px;
}

#headimg h1, #headimg #desc {
	display: none;
}
</style>
<?php
}


function header_style() {
?>
<style type="text/css" media="screen">
#header{background: url(<?php header_image() ?>) no-repeat center; border: none;}
</style>
<?php
}

//add_custom_image_header('header_style', 'violinesth_admin_header_style');

if ( ! function_exists('get_option') )
	die("This isn't what you're looking for. Try <a href=\"/\" title=\"Site Root\">this</a>.");

function get_violinesth_colors() {
	return array(
		'Default (3 Columns) ' => '',
		'2 Columns ' => 'styles');
}

function get_violinesth_color() {
	$violinesth_color = get_option('violinesth');
	
	return clean_violinesth_color($violinesth_color);
}

function violinesth_color_select() {
	echo "<select id='violinesth' name='violinesth'>";
	$colors = get_violinesth_colors();
	$current_color = get_violinesth_color();
	foreach ( $colors as $name => $value ) {
		$selected = ($current_color == $value) ? " selected='selected'" : '';
		echo "<option value='$value'$selected>$name</option>";
	}
	echo "</select>\n";
}

function violinesth_color_radios() {
	$colors = get_violinesth_colors();
	$current_color = get_violinesth_color();
	$theme_uri = get_template_directory_uri();
	$i = 0;
	foreach ( $colors as $name => $value ) {
		$checked = ($current_color == $value) ? " checked='checked'" : '';
		$filename = "preview{$value}.jpg";
		echo "<tr valign='middle'><td align='right'><input type='radio' name='violinesth_color' id='violinesth_color_{$i}' value='{$value}'$checked /></td><td><label for='violinesth_color_{$i}'> <img align='middle' src='{$theme_uri}/{$filename}' alt='{$name} Color Sample' /> $name</label></td></tr>\n";
		++$i;
	}
}

function clean_violinesth_color($violinesth_color) {
	$violinesth_colors = get_violinesth_colors();
	if ( in_array($violinesth_color, $violinesth_colors) )
		return $violinesth_color;
	else
		return '';
}

function violinesth_color() {
	echo get_violinesth_color();
}

function violinesth_css() {
	$violinesth_color = get_violinesth_color();

	$url = get_bloginfo('stylesheet_url');

	if ( !empty($violinesth_color) ) {
		$time = time();
		$url = str_replace('style.css', "{$violinesth_color}.css?{$time}", $url);
	}

	$url = apply_filters('bloginfo', $url, 'stylesheet_url');
	$url = convert_chars($url);
	echo $url;
}

add_action('admin_menu', 'violinesth_add_theme_page');

function violinesth_add_theme_page() {
	global $violinesth_message;
	if ( isset($_POST['action']) && 'violinesth_update' == $_POST['action'] ) {
		$color = clean_violinesth_color($_POST['violinesth']);
		update_option('violinesth', $color);

		$colors = array_flip(get_violinesth_colors());
		$Color = __($colors[$color]);
		$message = sprintf(__("Column changed to %s"), $Color);
		$violinesth_message = "<div style=\"background-color: rgb(207, 235, 247);\" id=\"message\" class=\"updated fade\"><p><strong>$message</strong></p></div>";
	}

	add_theme_page("Theme Column", "Column Setting", 'edit_themes', basename(__FILE__), 'violinesth_theme_page');
}

function violinesth_theme_page() {
	global $violinesth_message;
	echo $violinesth_message;
?>
<div class="wrap">
 <h2>Select a Theme Column</h2>

  <form method="post"> 
	<?php violinesth_color_select(); ?>

	<p class="submit"><input type="submit" name="Submit" value="Apply Theme" /></p>
	<input type="hidden" name="action" value="violinesth_update" /> 
  </form>

</div>
<?php
}
/*
function get_latest_post_feed() {
	include_once (ABSPATH . WPINC . '/rss.php');
	$rss = @fetch_rss('http://tags.bloggles.info/feed/');

	echo '<div class="post"><h2>Latest Journal</h2></div>';

	if ( is_array( $rss->items ) ) {

		$news = wp_cache_get('news');
		if ( false == $news ) {
			$rss->items = array_slice($rss->items, 0, 10);
			foreach ($rss->items as $item ) {
				$news .= "<div class='post'><div style='padding:8px;float:right'><a rel='nofollow' class='shot' href='".wp_filter_kses($item['link']) ."' title='". wp_specialchars($item['title']) ."'><img src='http://images.websnapr.com/?url=". wp_filter_kses($item['link']) ."&size=s&nocache=15' border='none' /></a></div><h2><a rel='nofollow' href='". wp_filter_kses($item['link']) ."' title='". wp_specialchars($item['title']) ."'>". wp_specialchars($item['title'])."</a></h2><div class='entry'>". wp_specialchars($item['description'])."</div></div><br style='clear:both;'>";
			}
			wp_cache_set('news', $news, 'theme', 21600); //cache for 6 hours
		}
	}

	echo $news;
}
*/
/*
function rssinpage($atts) {
	extract(shortcode_atts( array(
		'rssfeed' => 'no feed',
		'rssitems' => '5',
		'rssorder' => 'desc',
		'rssdateformat' => 'r',
		'rsstarget' => '_self',
		'rssdescription' => 'yes',
		'rssdescriptionlength' => 'all',
		'rsstitlelength' => 'all',
		'rssformat' => 'x: Y - w<br>z',
		'rsscss' => '',
		'rsstimezone' => 'UTC'
	), $atts ) );

$rsscachelocation = WP_CONTENT_DIR.'/cache'; 

if (!file_exists($rsscachelocation)) {
	mkdir($rsscachelocation, 0777);
}

if ($rssfeed != 'no feed') { 
	$rssformatsplit = str_split($rssformat);
	$rssformatdef = array('w','x','y','Y','z');
	$rssfeedarray = explode(",",$rssfeed);
	foreach ($rssfeedarray as &$feedurl) {
		$feedurl = trim($feedurl);
		$rss_urlcheck = stripos($feedurl, 'http');
		if ($rss_urlcheck !== 0) { $feedurl = 'http://'.$feedurl; }
		$feedurl = (html_entity_decode ($feedurl)); 
}

require_once (ABSPATH . WPINC . '/class-feed.php');
date_default_timezone_set($rsstimezone);
$feed = new SimplePie();
$feed->set_feed_url($rssfeedarray);
$feed->set_cache_location($rsscachelocation);
$feed->set_cache_duration('60');
if ($rssorder == 'none') { $feed->enable_order_by_date(false); }
$feed->init();
$feed->handle_content_type();
$rss = $feed;
$maxitems = $rss->get_item_quantity(50);
if ($maxitems != 0) {
	$rss_items = $rss->get_items(0, $maxitems);
	if ($rssitems > $maxitems) $rssitems = $maxitems;
	if ($rssorder == 'asc') $rss_items = array_reverse($rss_items);
	$i=0;
	while ($i < $rssitems) {
	$w = $rss_items[$i]->get_feed()->get_title();
	if ($rss_items[$i]->get_date() != '') $x = $rss_items[$i]->get_date($rssdateformat);
		$rsstitle = $rss_items[$i]->get_title();
		$rsslinketitle = $rsstitle;
	if ($rsstitlelength != 'all') { 
		if(strlen($rsstitle) > $rsstitlelength) { $rsstitle = substr($rsstitle, 0, $rsstitlelength).'... '; }
}
$y = $rsstitle;
if ($rss_items[$i]->get_permalink() != '') {
	$rss_itemlink = $rss_items[$i]->get_permalink();
	$rss_itemlinkstart = strrpos($rss_itemlink, "http://");
	$rss_itemlink = substr($rss_itemlink, $rss_itemlinkstart);
	$Y = '<a href="'.$rss_itemlink.'" target="'.$rsstarget.'" title="'.$rsslinketitle.'">'.$rsstitle.'</a>'; } else { $Y = $rsstitle; }
	if ($rss_items[$i]->get_description() != '') $z = $rss_items[$i]->get_description();
	if ($rssdescriptionlength != 'all') { 
	if(strlen($z) > $rssdescriptionlength) { $z = substr($z, 0, $rssdescriptionlength).'... '; }
}

if ($rssdescription == 'no') $z = '';
	foreach ($rssformatsplit as $v) { if (in_array($v, $rssformatdef)) { $v = ${$v}; }
	$rssformatoutput = $rssformatoutput.$v;
}

$rssreturn = $rssreturn.'<li>'.$rssformatoutput.'</li>';
	unset($rssformatoutput, $w, $x, $Y, $y, $z);
	$i++;
}	
	if (!empty($rsscss)) { $rssipul = '<ul class="'.$rsscss.'">'; } else { $rssipul = '<ul>'; }
		return $rssipul.$rssreturn.'</ul>';
	}
}	
}

add_shortcode("rssinpage", "rssinpage");
*/
?>